<template>

</template>
<!-- <template>
<view>
	<canvas class="center" style="width: 300px;height: 300px;margin-bottom: 50px;" canvas-id="mycanvas" />
	<button type="default" class="btn" @click="saveEwm">保存图片</button>
</view>
</template>

<script>
	import {hy} from '../../utils/api.js'
	import {QR} from '../../utils/code.js'
	import config from '../../utils/config.js'
	const head = config.baseUrl
	export default {
		data() {
			return {
				qr:'',
				img:''
			}
		},
		onLoad(option){
			this.meeting_id = option.meeting_id						
			this.createQrCode(JSON.stringify({meeting_id:this.meeting_id}),'mycanvas', 300, 300)
		},
		methods: {
			createQrCode(content, canvasId, cavW, cavH) {
					//调用插件中的draw方法，绘制二维码图片
					//this.canvasToTempImage 为绘制完成的回调函数，可根据自己的业务添加
					QR.api.draw(content, canvasId, cavW, cavH, this);
					setTimeout(()=>{
						this.canvasToTempImage(canvasId)
					},500)
			},
			//获取临时缓存图片路径，存入data中
			canvasToTempImage(canvasId) {
				let that = this
					wx.canvasToTempFilePath({
						canvasId, // 这里canvasId即之前创建的canvas-id
						success: (res) => {
							let tempFilePath = res.tempFilePath; // 这里可以获取到生成二维码的图片地址
							that.img = tempFilePath
						},
						fail: (res) => {
							console.log(res);
						}
					});
			},
			saveEwm(url){
				let _this = this;
				uni.showLoading({ mask:true,
					title:'保存中...'
				})
				uni.saveImageToPhotosAlbum({
						filePath: _this.img,
						success: () => {
								uni.hideLoading();
								uni.showToast({
									title:'图片已保存'
								})
						},
						fail: () => {
								uni.hideLoading();
								uni.showToast({
									title:'保存失败',
									icon:'none'
								})
						},
						complete: () => {
						}
				});
			}
		}
	}
</script>

<style scoped lang="scss">
.center{
	margin: 0 auto;
}
.btn{
	width: 80%;
	margin-left: 10%;
}
</style>
 -->